package com.xgst.lib.utils

import android.content.Context
import android.graphics.Point
import android.view.WindowManager

object ScreenUtils {

    fun getScreenWidth(context: Context) = context.resources.displayMetrics.widthPixels

    fun getScreenHeight(context: Context) = context.resources.displayMetrics.heightPixels

    /**
     * 将dp值转换为px值
     */
    fun dp2px(context: Context, dpValue: Int): Int {
        val scale = context.resources.displayMetrics.density
        return (dpValue * scale + 0.5f).toInt()
    }

    /**
     * 将px值转换为dp值
     */
    fun px2dp(context: Context, pxValue: Int): Int {
        val scale = context.resources.displayMetrics.density
        return (pxValue / scale + 0.5f).toInt()
    }
}